package leetcode_day._2021._202108._2131;

/**
 * @author yzh
 * @version 1.0
 * @date 2021/8/28 14:56
 * 一维数组的动态和
 * 算法：前缀和
 */
public class _28_1480 {

    public int[] runningSum(int[] nums) {
        int n = nums.length;
        int[] ans = new int[n];
        for (int i = 0; i < n; i++) {
            if (i == 0) ans[i] = nums[i];
            else ans[i] = ans[i - 1] + nums[i];
        }
        return ans;
    }

}
